﻿using System;

using DevExpress.Xpo;

using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;
using System.ComponentModel;
using DevExpress.ExpressApp;
using DevExpress.Data.Filtering;

namespace SpeedSCM.Module
{
    [NavigationItem("资金管理")]
    [ImageName("BO_Sale_Item")]
    public class 收款单 : 单据
    {
        public 收款单(Session session)
            : base(session)
        {

        }
        protected override SeedType SeedType
        {
            get { return SeedType.收款单; }
        }

        private 往来单位 _付款单位;
        [Custom("Caption", "付款单位")]
        [RuleRequiredField(null, DefaultContexts.Save, "必须选择付款单位")]
        public 往来单位 付款单位
        {
            get { return _付款单位; }
            set { SetPropertyValue<往来单位>("付款单位", ref _付款单位, value); }
        }

        [Association("收款单-收款单明细")]
        public XPCollection<收款单明细> 收款单明细
        {
            get
            {
                return GetCollection<收款单明细>("收款单明细");
            }
        }
    }

    [ImageName("BO_Sale_Item")]
    [RuleCombinationOfPropertiesIsUnique(null, DefaultContexts.Save, "收款单,收款账户名称", CustomMessageTemplate = "收款单中已经存在该收款账户")]
    public class 收款单明细 : BaseObject
    {
        public 收款单明细(Session session)
            : base(session)
        {

        }
        private 收款单 _收款单;
        [Custom("Caption", "收款单")]
        [Association("收款单-收款单明细")]
        [Custom("AllowEdit", "False")]
        public 收款单 收款单
        {
            get { return _收款单; }
            set { SetPropertyValue<收款单>("收款单", ref _收款单, value); }
        }
        private 银行账户 _收款账户名称;
        [Custom("Caption", "收款账户名称")]
        [RuleRequiredField(null, DefaultContexts.Save, "必须选择收款账户")]
        public 银行账户 收款账户名称
        {
            get { return _收款账户名称; }
            set { SetPropertyValue<银行账户>("收款账户名称", ref _收款账户名称, value); }
        }

        private decimal _金额;
        [Custom("Caption", "金额")]
        [RuleRequiredField]
        public decimal 金额
        {
            get { return _金额; }
            set { SetPropertyValue<decimal>("金额", ref _金额, value); }
        }
        private string _备注;
        [Custom("Caption", "备注")]
        [Size(500)]
        public string 备注
        {
            get { return _备注; }
            set { SetPropertyValue<string>("备注", ref _备注, value); }
        }
    }
}
